package com.lwm.controller;


import com.github.pagehelper.PageInfo;
import com.lwm.domain.SalesContract;
import com.lwm.domain.ResponseResult;
import com.lwm.dto.SalesContractDto;
import com.lwm.service.SalesContractService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/salesContract")
public class SalesContractController {
    @Resource
    private SalesContractService salesContractService;

    /**
     * 添加
     *
     * @param salesContract 销售合同
     * @return {@link ResponseResult}<{@link Object}>
     */
    @PostMapping
    public ResponseResult<Object> save(@RequestBody SalesContract salesContract) {
        return salesContractService.save(salesContract);
    }

    /**
     * 删除
     *
     * @param ids ids
     * @return {@link ResponseResult}<{@link Object}>
     */
    @DeleteMapping("/{ids}")
    public ResponseResult<Object> remove(@PathVariable List<Long> ids) {
        return salesContractService.remove(ids);
    }

    /**
     * 编辑
     *
     * @param salesContract 销售合同
     * @return {@link ResponseResult}<{@link Object}>
     */
    @PutMapping
    public ResponseResult<Object> edit(@RequestBody SalesContract salesContract) {
        return salesContractService.update(salesContract);
    }

    /**
     * 分页
     *
     * @param salesContractDto 销售合同dto
     * @return {@link ResponseResult}<{@link List}<{@link SalesContract}>>
     */
    @PostMapping("/page")
    public ResponseResult<List<SalesContract>> page(@RequestBody SalesContractDto salesContractDto) {

        return salesContractService.page(salesContractDto);
    }

}
